#include <algorithm>
#include <iostream>

#include "matrix.h"

using namespace std;
using namespace ads;

void view(int v) {
  cout << v << " ";
}

int main(int argc, char *argv[]) {
  int **x = new int*[4];
  for (int i = 0; i < 4; ++i) {
    x[i] = new int[4];
  }
  int val = 1;
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) {
      x[i][j] = val++;
    }
  }

  int* result = Matrix::snake(x, 4, 4);
  for_each(result, &result[4*4], view);
  cout << endl;
  delete[] result;

  for (int i = 0; i < 4; ++i) {
    delete[] x[i];
  }
  delete[] x;

  return 0;
}

